package fm.dongman.animefm.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import fm.dongman.animefm.R;
import fm.dongman.animefm.contractlib.IModel;
import fm.dongman.modellib.model.ComicModel;

/**
 * 新番速递adapter
 * Created by alex on 2017/10/16.
 */

public class ComicLatestAnimeAdapter extends RecyclerView.Adapter <ComicLatestAnimeAdapter.ViewHolder>{

    private Context mContext;
    private List<IModel.IComicModel> mComicModelList;

    public ComicLatestAnimeAdapter(Context context, List<IModel.IComicModel> comicModelList) {
        mContext = context;
        mComicModelList = comicModelList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(View.inflate(mContext, R.layout.item_comic_latest_anime,null));
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ComicModel comic= (ComicModel) mComicModelList.get(position);
        Glide.with(mContext).load(comic.getImgUrl()).into(holder.mImgUrl);
        Log.i("-0-tu:",comic.getImgUrl()+"   ");
        holder.mTvTitle.setText(comic.getTitle());
        holder.mTvType.setText("暂无/类型/数据");
        holder.mTvDirector.setText("暂无导演");
        holder.mTvUpdateInfo.setText(comic.getYear()+"  更新至第"+comic.getEpisodes()+"话");
    }

    @Override
    public int getItemCount() {
        return mComicModelList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView mImgUrl;
        TextView mTvTitle;
        TextView mTvType;   //类型
        TextView mTvDirector;   //导演
        TextView mTvUpdateInfo; //时间+更新多少话

        public ViewHolder(View itemView) {
            super(itemView);
            mImgUrl= (ImageView) itemView.findViewById(R.id.roundedImageView);
            mTvTitle= (TextView) itemView.findViewById(R.id.mTvComicLatestTitle);
            mTvType= (TextView) itemView.findViewById(R.id.mTvComicLatestType);
            mTvDirector= (TextView) itemView.findViewById(R.id.mTvComicLatestDirector);
            mTvUpdateInfo= (TextView) itemView.findViewById(R.id.mTvComicLatestUpdateInfo);
        }
    }
}
